package com.yongchun.service.impl;


import com.yongchun.commons.StringUtil;
import com.yongchun.dao.IChargeRecordsDao;
import com.yongchun.modelExt.ChargeRecordsExt;
import com.yongchun.pubInter.BaseService;
import com.yongchun.pubInter.SkException;
import com.yongchun.search.ChargeRecordsSearch;
import com.yongchun.service.IChargeRecordsService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author afeng
 * @version 1.0
 * @date 2023/2/17 下午2:09
 */
@Service
public class ChargeRecordsServiceImpl extends BaseService<ChargeRecordsExt, ChargeRecordsSearch,String> implements IChargeRecordsService {
    @Autowired
    private IChargeRecordsDao chargeRecordsDao;
    @Override
    public MongoRepository<ChargeRecordsExt, String> getDao() {
        return chargeRecordsDao;
    }

//    @Override
//    public List<TableJoin> getTabelJoinList() {
//
//        List<TableJoin> tableJoinList = SkList.getInstance();
//        TableJoin playerJoin=new TableJoin("player","pay_player_id","_id","player");
//        playerJoin.setShowFieldList(SkList.getInstance().addObjToList(new TableJoinShowField("name","playerName")).addObjToList(new TableJoinShowField("userId","playerUserId")));
//        tableJoinList.add(playerJoin);
//
//        return tableJoinList;
//    }



    @Override
    public ChargeRecordsExt getDetailByOrderNum(String orderNum) throws SkException {
        List<ChargeRecordsExt> chargeRecordsExts=getAll(new ChargeRecordsSearch().setOrderNumEq(orderNum));
        if(StringUtil.isNotObjEmpty(chargeRecordsExts)&&chargeRecordsExts.size()>0){
            return  chargeRecordsExts.get(0);
        }
        return null;
    }

    @Override
    public ChargeRecordsExt getDetailByThirdPayId(String thirdPayId) throws SkException {
        List<ChargeRecordsExt> chargeRecordsExts=getAll(new ChargeRecordsSearch().setThirdPayIdEq(thirdPayId));
        if(StringUtil.isNotObjEmpty(chargeRecordsExts)&&chargeRecordsExts.size()>0){
            return  chargeRecordsExts.get(0);
        }
        return null;
    }
}
